class Vehicle {
  brand
  year
  static vehicleCount = 1
  constructor(brand, year) {
    this.brand = brand
    this.year = year
  }
  #dateIsFit(birthdayDate) {
    const today = new Date()
    const birthDate = new Date(birthdayDate)
    const yearDiffer = today.getFullYear() - birthDate.getFullYear()
    const monthDiffer = today.getMonth() - birthDate.getMonth()
    if (yearDiffer > 0 || (yearDiffer === 0 && monthDiffer >= 0)) {
      return true
    } else {
      return false
    }
  }
  getInfo() {
    return `车辆基本信息：品牌：${this.brand}、生产年份：${this.year}`
  }
  static incrementVehicleCount(num) {
    Vehicle.num++
    console.log(`当前共有${this.vehicleCount + num}辆车`);
    return this.vehicleCount + num
  }
}

class Car extends Vehicle {
  mileage
  constructor(mileage, ...args) {
    super(...args)
    this.mileage = mileage
  }
  get mileageInfo() {
    return `车辆的里程数：${this.mileage}`
  }
  set mileageInfo(updateMileage) {
    this.mileage = updateMileage
  }
  drive(incrementMileage) {
    // Car.incrementMileage++
    // return this.mileage + incrementMileage
    this.mileage += incrementMileage
    return this.mileage
  }
  getInfo() {
    return `车辆的品牌：${this.brand}, 生产年份：${this.year}, 里程数：${this.mileage}`
  }
  static compareMileage(car1, car2) {
    return car1.mileage > car2.mileage ? car1 : car2
  }
  getVehicleCount(num) {
    Vehicle.incrementVehicleCount(num)
  }
}

const car1 = new Car('宝马', 2010, 100000)
const car2 = new Car('奔驰', 2015, 200000)
car1.drive(1000)
car1.getInfo()
const bigCar = Car.compareMileage(car1, car2)
console.log(bigCar.getInfo())
car1.getVehicleCount(10) 
